package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.Address;
import service.AddressServiceImpl;

/**
 * Servlet implementation class XiugaiAddress
 */
@WebServlet("/XiugaiAddressServlet.do")
public class XiugaiAddressServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Address address = new Address();
		String sheng= request.getParameter("province");
		String shi = request.getParameter("city1");
		String qu = request.getParameter("city2");
		String userName = request.getParameter("username");
		String addr = request.getParameter("addr");
		String userPhone= request.getParameter("userphone");
		String userIdentify = request.getParameter("useridentify");
		String newaddress = sheng + shi + qu + addr;
		
		address.setUserAddress(newaddress);
		address.setUserIdentify(userIdentify);
		address.setUserPhone(userPhone);
		address.setUserName(userName);
		
		
		AddressServiceImpl addressServiceImpl = new AddressServiceImpl();
		int result = addressServiceImpl.updateAddressByName(address);
	
	    request.getRequestDispatcher("AllAddressServlet.do").forward(request, response);
	    	
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
